﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ApprovalUtilities.Persistence;
using Microsoft.Reporting.WinForms;

namespace DatabaseTest
{
   public  class ReportGenerator
    {
       public static byte[] ShowCustomers()
       {
           return ShowCustomers(new AdventureWorksLTLoader(10000, @"server=.\sqlexpress;database=Insults;trusted_connection=true"));
       }
       public static byte[] ShowCustomers(ILoader<Customers[]> loader)
       {
           var customers = loader.Load();
           var r = new ReportViewer();
           r.LocalReport.ReportEmbeddedResource = "DatabaseTest.BigCustomers.rdlc";
           r.LocalReport.DataSources.Add(new ReportDataSource("Model", customers ));
           r.RefreshReport();
           string fn;
           string[] st;
           Warning[] w;
           string mime;
           string e;
           return r.LocalReport.Render("IMAGE",null,out mime,out e,out fn, out st, out w);
       }
    }
}
